home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar
/
1998
/
Nov
/
di9811gd
/
Example1
/
DllCode.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-11-02
|
1KB
|
56 lines
unit DllCode;
interface
uses
Dialogs, SysUtils;
{ Assume that szResult is at least as long as sz }
procedure GetFirstWord(sz, szResult: PChar); stdcall export;
procedure GetNextWord(sz, szResult: PChar); stdcall export;
implementation
var
gCurrentWordIndex: Integer;
function FindCurrentWord(st: String): String;
var
Len, j: Integer;
begin
j := gCurrentWordIndex; Len := Length(st);
{* Find where the word begins... *}
while (j <= Len) and
(not (st[j] in ['A'..'Z','a'..'z','0'..'9'])) do Inc(j);
gCurrentWordIndex := j;
{* Find where the word ends... *}
while (j <= Len) and
(st[j] in ['A'..'Z','a'..'z','0'..'9']) do Inc(j);
result := Copy(st, gCurrentWordIndex, j - gCurrentWordIndex + 1);
gCurrentWordIndex := j;
end;
procedure GetFirstWord(sz, szResult: PChar);
var
st: String;
begin
gCurrentWordIndex := 1;
StrPCopy(szResult, FindCurrentWord(String(sz)));
end;
procedure GetNextWord(sz, szResult: PChar);
begin
StrPCopy(szResult, FindCurrentWord(String(sz)));
end;
initialization
gCurrentWordIndex := 0;
ShowMessage('Initializing process-level stuff.');
finalization
ShowMessage('Cleaning up process-level stuff.');
end.